import os
import sys

def get_project_root():
    """动态获取项目根目录"""
    if getattr(sys, 'frozen', False):
        return sys._MEIPASS
    else:
        return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

def resolve_path(*args):
    """统一路径解析接口"""
    base_dir = get_project_root()
    return os.path.join(base_dir, *args)

def resolve_config_path(filename):
    """确保正确处理打包后的路径"""
    base_dir = get_project_root()
    # 开发环境路径: 项目根目录/conf/
    # 打包环境路径: 临时目录/conf/
    config_path = os.path.join(base_dir, 'conf', filename)
    print(f"[PATH_DEBUG] 配置文件路径: {config_path}")  # 新增调试输出
    return config_path

def resolve_sample_path(filename):
    """解析样本文件路径"""
    return resolve_path('samples', filename)